package com.jeasonzhao.report.decorator;

import com.jeasonzhao.report.dataset.DataSet;
import com.jeasonzhao.report.exceptions.DecoratorException;
import com.jeasonzhao.report.exceptions.RenderException;
import com.jeasonzhao.report.model.Report;
import com.jeasonzhao.report.model.chart.Chart;

public class ChartModelDataSetDecorator
{
    private ChartModelDataSetDecorator()
    {
    }

    public static void calcChartsData(Report report,DataSet dataset)
        throws DecoratorException
    {
        try
        {
            if(null == report ||
               null == dataset ||
               null == dataset.getHeaderColumns() ||
               null == report.getChartModels() ||
               report.getChartModels().size() < 1)
            {
                return;
            }
            for(int n = 0;n < report.getChartModels().size();n++)
            {
                Chart chartModel = report.getChartModels().get(n);
                chartModel.initDataSet(dataset);
            }
        }
        catch(RenderException ex)
        {
            //throw new DecoratorException(ex);
        }
    }

}
